/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package extension.room.handler;

import com.smartfoxserver.v2.entities.User;
import com.smartfoxserver.v2.entities.data.ISFSObject;
import com.smartfoxserver.v2.extensions.BaseClientRequestHandler;
import extension.room.phom.PhomExtension;
import extension.room.phom.PhomGame;
import extension.room.phom.PhomPlayer;

/**
 *
 * @author daz
 */
public class SkipTurnHandler extends BaseClientRequestHandler {

    @Override
    public void handleClientRequest(User user, ISFSObject params) {
        PhomExtension tienlenExtension = (PhomExtension) getParentExtension();
        PhomGame game = tienlenExtension.getGame();
        PhomPlayer[] listPlayers = game.getListPlayers();
        for (int i = 0; i < game.getMaxPlayer(); i++) {
            if (listPlayers[i] != null && listPlayers[i].getState() == PhomPlayer.PLAYING) {
                if (listPlayers[i].getName().equals(user.getName())) {
                    game.skipTurn(i);
                }
            }
        }
    }
}
